<!DOCTYPE html>
<html lang=en>
<head>
  <meta http-equiv=content-type content="text/html; charset=utf-8" />
  <meta name=viewport content="width=device-width, initial-scale=1">

  <title>${meta.title} REST Documentation</title>
  <link rel=stylesheet type=text/css href=styles/docs.css />
</head>
<body>
<header class=center>
  <a href=/>
  <img src=/img/logo/opencast.svg alt=Opencast style="width: 180px;" />
  </a>
</header>

<h1><div class=center>${meta.title} REST Documentation</div></h1>

<summary>
  <div class=center>
    <div>${meta.url}</div>
    <div>${(meta.abstract)!}</div>
  </div>
</summary>

<main class=center>

<!-- GENERAL NOTES -->
<#list notes>
<h2>General Notes</h2>
<ul>
  <#items as note>
  <li>${note}</li>
  </#items>
</ul>
</#list>

<!-- TABLE OF CONTENTS -->

<h2>Table of Contents</h2>
<ul class="toc">
  <#list endpointHolders as endpointHolder>
  <#list endpointHolder.endpoints as endpoint>
  <li><a href="#${endpoint.name}-${endpoint?counter}">${endpoint.method} ${endpoint.path}</a></li>
  </#list>
  </#list>
</ul>

<!-- ENDPOINTS -->

<#list endpointHolders as endpointHolder>
<#list endpointHolder.endpoints>
<h2>${endpointHolder.title} methods</h2>
<#items as endpoint>
<table id="${endpoint.name}-${endpoint?counter}" class="method" cellpadding="0px" cellspacing="0px"
  summary="${endpointHolder.title} function for the ${endpoint.method} ${endpoint.path} REST endpoint, Name of the attribute followed by the value">
  <thead>
    <tr>
      <th>Method / Path:</th>
      <th title="${meta.url}${endpoint.path}">${endpoint.method} ${endpoint.path}</th>
    </tr>
  </thead>
  <tbody>
    <tr class="method">
      <th scope="row">Description:</th>
      <td>${endpoint.description!"<em>NONE</em>"}</td>
    </tr>
    <tr class="method">
      <th class="method_important" scope="row">Path params:</th>
      <td>
        <#list endpoint.pathParams as param>
        <tt>${param.name}<#if param.defaultValue??>&#40;Default value=${param.escapedDefaultValue}&#41;</#if></tt>:
        ${param.description!"<em>NONE</em>"}<#sep><br/></#sep>
        <#else>
        <em>NONE</em>
        </#list>
      </td>
    </tr>
    <#if (endpoint.requiredParams?size > 0)>
    <tr class="method">
      <th class="method_important" scope="row">Required (form) params:</th>
      <td>
        <#list endpoint.requiredParams as param>
        <tt>
          ${param.name}: ${param.description!""}
          <#if param.xmlSchema??>
            <div>
              <a href="#" class="show_form_link">XML Schema</a>
              <div class="hidden_form hidden">
                <#if param.escapedXmlSchema??><pre>${param.escapedXmlSchema}</pre></#if>
              </div>
              <a href="#" class="hide_form_link hidden">Hide</a>
            </div>
          </#if>
        </tt><#if param_has_next> <br/></#if>
        </#list>
      </td>
    </tr>
    </#if>
    <#if endpoint.bodyParam??>
    <tr class="method">
      <th class="method_important" scope="row">Body (upload) param:</th>
      <td>
        <#if endpoint.bodyParam.defaultValue??>
        <tt>&#40;Default value=${endpoint.bodyParam.escapedDefaultValue}&#41;</tt>:
        </#if>${endpoint.bodyParam.description!"<em>NONE</em>"}
      </td>
    </tr>
    </#if>
    <tr class="method">
      <th scope="row">Optional (<#if (endpoint.method == "GET" || endpoint.method == "DELETE")>query<#else>form</#if>) params:</th>
      <td>
        <#list endpoint.optionalParams as param>
        <tt>${param.name}<#if param.defaultValue??>&#40;Default value=${param.escapedDefaultValue}&#41;</#if></tt>:
        ${param.description!"<em>NONE</em>"}<#sep> <br/></#sep>
        <#else>
        <em>NONE</em>
        </#list>
      </td>
    </tr>
    <#if (endpoint.formats?size > 0)>
    <tr class="method">
      <th scope="row">Response formats:</th>
      <td>
        <#list endpoint.formats as format>
        <#if format.url??><a href="${format.url}">${format.name}</a><#else>${format.name}</#if>
        <#if format.description??>(${format.description})</#if><#sep><br/></#sep>
        </#list>
      </td>
    </tr>
    </#if>
    <tr class="method">
      <th scope="row">Status codes:</th>
      <td>
        <#list endpoint.statuses as status>
        <tt>${status.code}: ${status.name}</tt>, ${status.description!"<em>NONE</em>"}<#if status_has_next> <br/></#if>
        <#else>
        <em>NONE</em>
        </#list>
      </td>
    </tr>
    <#if (endpoint.returnTypeSchema??)>
      <tr class="method">
        <th scope="row">Returned Entity Schema:</th>
        <td>
          <div>
            <a href="#" class="show_form_link">Click to view</a>
            <div class="hidden_form hidden">
              <#if endpoint.escapedReturnTypeSchema??><pre>${endpoint.escapedReturnTypeSchema}</pre></#if>
            </div>
            <a href="#" class="hide_form_link hidden">Hide</a>
          </div>
        </td>
      </tr>
    </#if>
    <#if (endpoint.notes?size > 0)>
    <tr class="method">
      <th scope="row">Notes:</th>
      <td>
        <ul>
          <#list endpoint.notes as note>
          <li>${note}</li>
          </#list>
        </ul>
      </td>
    </tr>
    </#if>
    <tr class="method testform">
      <th scope="row">Testing:</th>
      <td>
        <div class="spaced"><strong>Sample:</strong>
        <tt class="sample_url">${endpoint.path}${endpoint.queryString!}</tt>
        </div>
        <#if endpoint.form??>
        <#if (endpoint.form.basic)><#-- link to the basic endpoint path -->
        <a href="${meta.url}${endpoint.path}${endpoint.queryString!}">${meta.url}${endpoint.path}${endpoint.queryString!}</a>
        <#else>
        <a href="#" class="show_form_link">Testing form (click to reveal)</a>
        <div class="hidden_form hidden">
          <form id="form_${endpoint.name}-${endpoint?counter}"
                class="form_test_form"
                action="${meta.url}${endpoint.path}"
                method="${endpoint.method?lower_case}"<#if endpoint.form.fileUpload> enctype="multipart/form-data"</#if>>
            <input class="form_action_holder" type="hidden" value="${meta.url}${endpoint.path}" />
            <input class="form_endpoint_name" type="hidden" value="${endpoint.name}-${endpoint?counter}" />
            <input class="form_method" type="hidden" value="${endpoint.method}" />
            <#if (endpoint.form.ajaxSubmit)>
            <input class="form_ajax_submit" type="hidden" value="1" />
            </#if>
            <div class="spaced">
                <strong>Form action:</strong> <tt class="form_path">${meta.url}${endpoint.path}</tt>
            </div>
            <table class="testing" cellpadding="0" cellspacing="0">
              <#list endpoint.form.items as item>
              <tr class="form_field <#if item.required>form_required<#else>form_optional</#if>">
                <#if item.type == "text">
                <td class="form_textarea" colspan="3">
                  <label for="${endpoint.name}-${endpoint?counter}_${item.name}">${item.name}</label>:<br/>
                  <textarea id="${endpoint.name}-${endpoint?counter}_${item.name}"
                            name="${item.name}"
                            class="form_field_text form_param_submit<#if item.required> form_param_required</#if>"
                            rows="<#if item.attributes.rows??>${item.attributes.rows}<#else><#if item.name == "BODY">8<#else>3</#if></#if>"
                            cols="${(item.attributes.cols)!'80'}">${item.defaultValue!}</textarea>
                  <div class="form_field_description">${item.description!}</div>
                </td>
                <#elseif item.type == "boolean">
                <td class="form_label">
                  <#if item.required><span title="required">*</span>&nbsp;</#if><label for="${endpoint.name}-${endpoint?counter}_${item.name}">${item.name}</label>:
                </td>
                <td>
                  <input id="${endpoint.name}-${endpoint?counter}_${item.name}"
                         name="${item.name}"
                         class="form_field <#if item.path>form_param_path<#else>form_param_submit</#if><#if item.required> form_param_required</#if>"
                         type="checkbox"
                         value="true"
                         <#if item.defaultValue?? && item.defaultValue == "true">checked</#if> />
                </td>
                <td class="form_field_description">${item.description!}</td>
                <#elseif item.type == "file">
                <td class="form_label">
                  <#if item.required><span title="required">*</span>&nbsp;</#if><label for="${endpoint.name}-${endpoint?counter}_${item.name}">${item.name}</label>:
                </td>
                <td>
                  <input id="${endpoint.name}-${endpoint?counter}_${item.name}"
                         name="${item.name}"
                         class="form_field_file"
                         class="form_field form_param_upload<#if item.required> form_param_required</#if>"
                         type="file" />
                </td>
                <td class="form_field_description">${item.description!}</td>
                <#else>
                <td class="form_label">
                  <#if item.required><span title="required">*</span>&nbsp;</#if><label for="${endpoint.name}-${endpoint?counter}_${item.name}">${item.name}</label>:
                </td>
                <td>
                  <input id="${endpoint.name}-${endpoint?counter}_${item.name}"
                         class="form_field <#if item.path>form_param_path<#else>form_param_submit</#if><#if item.required> form_param_required</#if>"
                         name="${item.name}"
                         type="text"
                         value="${item.defaultValue!}"
                         size="${(item.attributes.size)!'30'}" />
                </td>
                <td class="form_field_description">${item.description!}</td>
                </#if>
              </tr>
              </#list>
              <tr>
                <td colspan="3">
                  <div class="form_submit">
                    <input type="submit" value="SUBMIT" />
                    <input type="button" value="CANCEL" />
                  </div>
                </td>
              </tr>
            </table>
          </form>
          <#if (endpoint.form.ajaxSubmit)>
          <div class="test_form_working hidden">... WORKING ...</div>
          <div class="test_form_response hidden">
            <div>Response:</div>
            <pre style="width: 100%; border-left: 4px solid #999; padding-left: 10px;"></pre>
          </div>
          </#if>
        </div>
        <a href="#" class="hide_form_link hidden">Hide</a>
        </#if>
      </td>
    </tr>
    </#if>
  </tbody>
</table>

</#items>
</#list>
</#list>

</main>

<!-- JAVASCRIPT below here -->
<script type=text/javascript src=js/jquery/dist/jquery.min.js></script>
<script type=text/javascript src=scripts/docs.js></script>

</body>
</html>
